import AntDesign from "@expo/vector-icons/AntDesign";
import { useRouter } from "expo-router";
import React, { useEffect, useRef } from "react";
import {
  StyleSheet,
  Text,
  TextInput,
  TouchableOpacity,
  View,
} from "react-native";
export default function MineScreen() {
  const inputRef = useRef<TextInput>(null);
  const router = useRouter();
  useEffect(() => {
    setTimeout(() => {
      inputRef.current?.focus();
    }, 100);
  }, []);
  return (
    <View style={styles.page}>
      <View style={styles.topBar}>
        <TouchableOpacity
          style={styles.backButton}
          onPress={() => router.back()}
        >
          <AntDesign name="left" size={24} color="black" />
        </TouchableOpacity>
        <View style={styles.searchLayout}>
          <AntDesign name="search1" size={18} color="grey" />
          <TextInput
            ref={inputRef}
            style={styles.searchTxt}
            placeholder="纯粮小麦粉"
            placeholderTextColor={"#bbb"}
          />
        </View>
        <Text style={styles.searchBotton}>搜索</Text>
      </View>
    </View>
  );
}
const styles = StyleSheet.create({
  page: {
    width: "100%",
    height: "100%",
    backgroundColor: "transparent",
  },
  searchLayout: {
    height: 32,
    flex: 1,
    backgroundColor: "#f0f0f0",
    borderRadius: 16,
    flexDirection: "row",
    alignItems: "center",
    paddingHorizontal: 16,
    marginLeft: 16,
  },
  searchTxt: {
    height: "100%",
    fontSize: 14,
    color: "#bbb",
    marginLeft: 6,
    paddingHorizontal: 8,
    paddingVertical: 0,
    paddingTop: 8,
    textAlignVertical: "center",
  },
  searchBotton: {
    fontSize: 16,
    color: "#666",
    marginHorizontal: 12,
  },
  topBar: {
    display: "flex",
    width: "100%",
    height: 40,
    flexDirection: "row",
    alignItems: "center",
    backgroundColor: "white",
  },
  backButton: {
    height: "100%",
    paddingLeft: 16,
    justifyContent: "center",
  },
});
